function where(collection, source) {
    let arr = [];
    let keys = Object.keys(source);
    arr = collection.filter(function (val) {
        for (let i = 0; i < keys.length; i++) {
            if (!val.hasOwnProperty(keys[i]) || val[keys[i]] !== source[keys[i]]) {
                return false;
            }
        }
        return true;
    });
    return arr;
}

let result = where([{first: "Romeo", last: "Montague"}, {first: "Mercutio", last: null}, {
    first: "Tybalt",
    last: "Capulet"
}], {last: "Capulet"});
console.log(result);
